#include "map.hpp"

vector<int> two_sum(vector<int> nums, int target)
{
    vector<int> result(2, -1); //初始化，长度为2，值为-1的容器
    unordered_map<int, int> map1;
    
    for(int i = 0; i < nums.size(); i++) {
        map1.insert({nums[i], i});
    }

    for(int i = 0; i < nums.size(); i++) {
        if (map1.find(target - nums[i]) != map1.end()) {
            result[0] = map1[target];
            result[1] = map1[target - nums[i]];
            break;
        }
    }
    return result;
}